import axios from '@/axios'

// 获取文件(文件夹)列表
export function getFileList(data) {
  return axios({
    url: '/chat-dx/myfolder/resources',
    method: 'post',
    data,
  })
}

// 新增文件夹
export function addFolder(data) {
  return axios({
    url: '/chat-dx/myfolder/addFolder',
    method: 'post',
    data,
  })
}

// 新增文件
export function addFile(data) {
  return axios({
    url: '/chat-dx/resource',
    method: 'post',
    data,
  })
}

// 修改文件(文件夹)
export function updateFile(data) {
  return axios({
    url: '/chat-dx/myfolder/update',
    method: 'post',
    data,
  })
}

// 上传文件(文件夹)
export function uploadFile(data) {
  return axios({
    url: '/chat-dx/myfolder/upload',
    method: 'post',
    data,
  })
}

//下载文件
export function downloadFile(resourceId) {
  return axios({
    url: '/chat-dx/resource/download/' + resourceId,
    method: 'get',
    responseType: 'blob',
  })
}

// 获取文件(文件夹)信息
export function getFileInfo(data) {
  return axios({
    url: '/chat-dx/resource/detail',
    method: 'post',
    data,
  })
}

// 删除文件(文件夹)
export function deleteFile(data) {
  return axios({
    url: '/chat-dx/myfolder/remove',
    method: 'post',
    data,
  })
}

// 查询文件分类
export function getFileType() {
  return axios({
    url: '/chat-dx/fileType/list',
    method: 'get',
  })
}

// 添加根文件夹
export function addRootFolder(data) {
  return axios({
    url: '/chat-dx/dx/menu',
    method: 'post',
    data,
  })
}

// 更新根文件夹
export function updateRootFolder(data) {
  return axios({
    url: '/chat-dx/dx/menu',
    method: 'put',
    data,
  })
}

// 删除根文件夹
export function delRootFolder(folderId) {
  return axios({
    url: `/chat-dx/dx/menu/${folderId}`,
    method: 'delete',
  })
}

// 获得根文件夹详情
export function getRootFolderInfo(folderId) {
  return axios({
    url: `/chat-dx/dx/menu/${folderId}`,
    method: 'get',
  })
}

// 获取根文件夹
export function getRootFolder() {
  return axios({
    url: '/chat-dx/folder/list',
    method: 'get',
  })
}

// 还原文件
export function resourceRestore(resourceId) {
  return axios({
    url: `/chat-dx/resourceRecycle/resourceRestore/${resourceId}`,
    method: 'get',
  })
}

// 彻底删除
export function removeForever(resourceId) {
  return axios({
    url: `/chat-dx/resourceRecycle/removeForever/${resourceId}`,
    method: 'get',
  })
}
